const net = require('net');
const { join } = require('path');
const rs = require('fs').createReadStream(join(__dirname,'text.txt'));

const server = net.createServer(socket => {
    rs.on('data',data => {
        const flag = socket.write(data); // boolear 可写流缓存区是否满了
        console.log(flag);
        console.log('缓存字节数=' + socket.bufferSize);
    });

    socket.on('drain', () => {
        console.log('tcp缓存区中的数据已经发送');
    })
});

server.listen(8080)